/*************************************************
*      Filename: calculate_total_evalation.cu
*        Coding: utf-8
*        Author: Futuan Li
*         Email: lifutuan@galasports.net
*      HomePage: http://www.galasports.net
*  Copyright(C): InnoReal Technology Co.,Ltd.
*       Version: 0.0.1
*    CreateDate: 2018-04-24 16:42:47
*    LastChange: 2018-07-06 17:19:50
*          Desc: 
*       History: 
*************************************************/

#include "calculate_total_evalation.h"

/*
	计算距离的限制：
            1) 关键帧如果是相邻的帧的编号，设置网格距离为0;
						2）第一关键帧如果不是第一帧的话，正常计算，否则设置为-1;
						3) 该关键帧所在位置编号的距离是由上一关键帧到该关键帧编号的上一帧的距离求得;
						4）当上一帧不存在的时候，利用第一帧的信息，当下一帧不存在的时候利用最后一帧的信息;
	
	计算矩阵的存储结构：
						1) sf_given X 2 的矩阵向量;
						2) 第一列为顺序，第二列为逆序;
*/


//Cal_Evalation函数的作用是计算所有关键帧间的距离(本文限制下的距离)， input:data(关键帧编号的数据）, sf_sum(所有帧的数量); output:evalate_dis(sf_given X 2的一个矩阵向量.)
void Calculate_Total_Evalation::Cal_Evalation_all(std::vector<int> data, int sf_sum) {

  InputData *input_data = new InputData;
  GNSolver *gn_solver = new GNSolver;
  DisTwoMesh *distmesh = new DisTwoMesh;
  char file_src[100], file_tar[100];

  evalate_dis_one.resize(data.size());
  for (int i = 0; i < data.size() - 1; i++) {
    printf("%d in calculate_Total_Evaluation Cal_Evalation_all, %d-> %d:", i, data[i],data[i]+1);
    sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]);
    sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i] + 2);
    input_data->Init(file_src, file_tar);
    for (int iter = 0; iter < 1; ++iter) {
      input_data->GetIijSet();
    }


    SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
    gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
    for (int iter = 0; iter < 10; ++iter) {
      gn_solver->Run(1);
    }



    double Dis = distmesh->Hausdorff_Average(input_data);
    evalate_dis_one[i] = Dis;  // ori: 0->1
    printf("  %f\n",Dis);
  }
  delete distmesh;
  delete gn_solver;
  delete input_data;
}

void Calculate_Total_Evalation::Cal_Evalation(std::vector<int> data, int sf_sum) {
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;
	char file_src[100],file_tar[100];
	// accoding to the vector data, initailize the vector evalate_dis, which servers as a evalation between a key frame and the next key frame or the front key frame;
	evalate_dis.resize(data.size()); 
	for(int i = 0; i < data.size(); i++) {
		printf("%d\n",i);
		evalate_dis[i].resize(2);
		if(data[i] == 0) { //第一关键帧若为第一帧时
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i+1]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]+1);
			if(data[i+1] - data[i] == 1)
				evalate_dis[i][1] = 0;  // ori: 0->1
			else {
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis[i][1] = Dis;  // ori: 0->1
			}
			evalate_dis[i][0] = -1;   // ori: 0->-1
		}
		else if(data[i] == sf_sum) {  // warnning:  212--> sf_sum : 213 in fact 最后一关键帧若为最后一帧时
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i-1]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i] - 1);
			if(data[i] - data[i-1] == 1)
				evalate_dis[i][0] = 0;  // ori: 0->1
			else {
				input_data->Init(file_src,file_tar);

				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);

				evalate_dis[i][0] = Dis;   // ori: 0->-1
			}
			evalate_dis[i][1] = -1;    // ori: 0->1
		}
		else {  // 第一关键帧既不是第一帧，最后一关键帧也不是最后一帧时
			if(i == 0) {//考虑第一关键帧的情况
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]);
				if(data[i] - 0 == 1)
					evalate_dis[i][0] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][0] = Dis;    // ori: 0->1
				}

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i+1]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]+1);
				if(data[i+1] - data[i] == 1)
					evalate_dis[i][1] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);

					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					//if(data[i] - data[i-1] == 1)
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);   // remove the sentence OK???
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][1] = Dis;   // ori: 0->-1
				}
			}
			else if(i == data.size()-1) { //考虑最后一关键帧的情况
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i-1]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i] - 1);
				if(data[i] - data[i-1] == 1)
					evalate_dis[i][0] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][0] = Dis;    // ori: 0->1
				}

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]);

				if(sf_sum - data[i] == 1)
					evalate_dis[i][1] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);   // remove the sentence OK???
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][1] = Dis;   // ori: 0->-1
				}
			}
			else { //考虑关键帧既不是第一关键帧也不是最有一关键帧的情况
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i-1]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]-1);
				if(data[i] - data[i-1] == 1)
					evalate_dis[i][0] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][0] = Dis;    // ori: 0->1
				}

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]+1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i+1]);
				if(data[i+1] - data[i] == 1)
					evalate_dis[i][1] = 0;  // ori: 0->1
				else {
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}

					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);   // remove the sentence OK???
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}

					double Dis = distmesh->Hausdorff_Average(input_data);
					evalate_dis[i][1] = Dis;   // ori: 0->-1
				}
			}
		}
	}
	delete distmesh;
	delete gn_solver;
	delete input_data;
}



//Cal_Evalation_Update函数的作用是计算给定相邻关键帧的距离，intput: data_front(该帧),data_next(下一帧); output:evalate_dis_one(一个1 X 2的vector). 
void Calculate_Total_Evalation::Cal_Evalation_Update( int data_front,  int data_next, int sf_sum) {
	// the information of meshes, deformation and distance function
	
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;
	char file_src[100],file_tar[100];
	// accoding to the vector data, initailize the vector evalate_dis, which servers as a evalation between a key frame and the next key frame or the front key frame;
	evalate_dis_one.resize(2); 
	if(data_next - data_front == 1) {
		evalate_dis_one[0] = 0;  // ori: 0->1
		evalate_dis_one[1] = 0;
	}
	else {
		sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data_front);
		sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data_next - 1);
		input_data->Init(file_src,file_tar);
		for (int iter = 0; iter < 1; ++iter) {
			input_data->GetIijSet();
		}
		SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
		gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
		for (int iter =0; iter < 10; ++iter) {
			gn_solver->Run(1);
		}
		double Dis = distmesh->Hausdorff_Average(input_data);
		evalate_dis_one[0] = Dis;  // ori: 0->1

		sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data_next);
		sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data_front + 1);
		input_data->Init(file_src,file_tar);
		for (int iter = 0; iter < 1; ++iter) {
			input_data->GetIijSet();
		}
		//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
		gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
		for (int iter =0; iter < 10; ++iter) {
			gn_solver->Run(1);
		}
		Dis = distmesh->Hausdorff_Average(input_data);
		evalate_dis_one[1] = Dis;  // ori: 0->1
	}
	
	delete distmesh;
	delete gn_solver;
	delete input_data;
}


// Cal_Evalation_Update_TP函数的作用是计算给定某一位置的上一帧到该帧的距离或该帧到下一帧的距离，input: data(关键帧数据),moving_position(移动点位置),
// bool_n(加一还是减一，用于表示移动的方向),sf_sum(总的帧的数量); output: evalate_dis_four(2 X 2).
void Calculate_Total_Evalation::Cal_Evalation_Update_TP(std::vector<int> data, int moving_position,  int bool_n,  int sf_sum) {
  //the information of meshes, deformation and distance function
  InputData *input_data = new InputData;
  GNSolver *gn_solver = new GNSolver;
  DisTwoMesh *distmesh = new DisTwoMesh;
  char file_src[100],file_tar[100];
  evalate_dis_four.resize(2);
  evalate_dis_four[0].resize(2);
  evalate_dis_four[1].resize(2);
  //
  if(bool_n == 1){ //关键帧移动位置加一操作
    if(moving_position == 0) { //当关键帧位置为第一关键帧的情况，则距离是通过0 帧到第一关键帧的距离
      evalate_dis_four[0][1] = 0;  //pass
      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]+1);
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      double Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[0][0] = Dis;  // ori: 0->1

      if(data[moving_position+1] - data[moving_position] == 2) {
        evalate_dis_four[1][0] = 0;
        evalate_dis_four[1][1] = 0;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] +1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][0] = Dis;  // ori: 0->1evalate_dis_four[1][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 2);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][1] = Dis;  // ori: 0->1evalate_dis_four[1][0] = Dis;  // ori: 0->1
      }
    }
    else if(moving_position == data.size() - 1) { //当关键帧为最后一帧的情况下
      if(sf_sum - data[moving_position] == 2 ){
        evalate_dis_four[1][0] = 0;
        evalate_dis_four[1][1] = 0;
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        double Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][0] = Dis;

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][1] = Dis;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        double Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][1] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][1] = Dis;  // ori: 0->1
      }
    }
    else{
      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] );
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      double Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[0][0] = Dis;  // ori: 0->1

      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] +1);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[0][1] = Dis;  // ori: 0->1

      if(data[moving_position+1] - data[moving_position] == 2){
        evalate_dis_four[1][0] = 0;
        evalate_dis_four[1][1] = 0;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 2);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][1] = Dis;  // ori: 0->1
      }
    }
  }
  //
  else if(bool_n == -1){ //关键帧位置减一操作
    if(moving_position == data.size() - 1) { //当关键帧位置为第最后一关键帧的情况
      evalate_dis_four[1][0] = 0;  //pass
      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]-1);
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      double Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[1][1] = Dis;  // ori: 0->1

      if(data[moving_position] - data[moving_position-1] == 2) {
        evalate_dis_four[0][0] = 0;
        evalate_dis_four[0][1] = 0;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 2);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][0] = Dis;  // ori: 0->1evalate_dis_four[1][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][1] = Dis;  // ori: 0->1evalate_dis_four[1][0] = Dis;  // ori: 0->1
      }
    }
    else if(moving_position == 0) { //当为第一关键帧的情况下
      evalate_dis_four[0][1] = 0; //pass
      if(data[moving_position] - 0 == 2 ){
        evalate_dis_four[0][0] = 0;

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] -1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        double Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][0] = Dis;

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][1] = Dis;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        double Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[1][1] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][0] = Dis;  // ori: 0->1
      }
    }
    else{ // 既不是第一关键帧也不是最后一个关键帧
      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1 );
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      double Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[1][0] = Dis;  // ori: 0->1

      sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
      sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
      input_data->Init(file_src, file_tar);
      for (int iter = 0; iter < 1; ++iter) {
        input_data->GetIijSet();
      }
      //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
      gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
      for (int iter = 0; iter < 10; ++iter) {
        gn_solver->Run(1);
      }
      Dis = distmesh->Hausdorff_Average(input_data);
      evalate_dis_four[1][1] = Dis;  // ori: 0->1

      if(data[moving_position] - data[moving_position - 1] == 2){
        evalate_dis_four[0][0] = 0;
        evalate_dis_four[0][1] = 0;
      }
      else{
        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 2);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][0] = Dis;  // ori: 0->1

        sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
        sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
        input_data->Init(file_src, file_tar);
        for (int iter = 0; iter < 1; ++iter) {
          input_data->GetIijSet();
        }
        //SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
        gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
        for (int iter = 0; iter < 10; ++iter) {
          gn_solver->Run(1);
        }
        Dis = distmesh->Hausdorff_Average(input_data);
        evalate_dis_four[0][1] = Dis;  // ori: 0->1
      }
    }
  }
  else{
    printf("Please output the right value, bool_n=: 1 or -1");
  }

  delete distmesh;
  delete gn_solver;
  delete input_data;
}



// Cal_Evalation_Update_TPN函数的作用是计算给定某个位置moving_position移动remove_N个点后的前一帧到该帧的距离或该帧到后一帧的距离，
// intput: data(关键帧的数据),moving_position(移动点的位置),bool_n(逻辑判断，目的是刻画顺序或逆序),sf_sum(总的帧的数量),remove_N(移动的关键点的个数);
// output:evalate_dis_four(remove_N个顶点移动后的距离).
void Calculate_Total_Evalation::Cal_Evalation_Update_TPN(std::vector<int> data, int moving_position,  int bool_n,  int sf_sum, int remove_N) {
	//the information of meshes, deformation and distance function
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;
	evalate_dis_removeN.resize(remove_N +1);
	for(int i=0; i<remove_N+1; i++){
		evalate_dis_removeN[i].resize(2);
	}
	char file_src[100],file_tar[100];
	if(bool_n == 1){ //关键帧移动位置加一操作
		if(data[moving_position] - data[moving_position - 1] == 2) {
			evalate_dis_removeN[0][0] = 0;
			evalate_dis_removeN[0][1] = 0;
		}
		else {
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1] + 2);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][1] = Dis;  // ori: 0->1
		}
		for(int i=1; i<remove_N; i++){
			if(data[moving_position -i] - data[moving_position - i - 1] == 1){
				evalate_dis_removeN[i][0] = 0;
				evalate_dis_removeN[i][1] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 - i] + 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i] );
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][0] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i] + 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 - i] + 2);
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][1] = Dis;  // ori: 0->1
			}
		}

		if(moving_position - remove_N == 0){  //在此情况下不可能等于0
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[0] );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1

			evalate_dis_removeN[remove_N][1] = 0;    // pass
		}
		else if(moving_position - remove_N > 0){
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 - remove_N]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N] );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N] + 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 - remove_N] + 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
		}
		else {
			printf("please ensure your parameter is right: the removing is too much!@");
		}
	}
	//关键帧做移动操作
	else if(bool_n == -1){
	  //第一关键帧
		if(moving_position == 0){
			if(data[moving_position] == 2){
				evalate_dis_removeN[0][0] = 0;
				evalate_dis_removeN[1][0] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] - 1 );
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[0][0] = Dis;  // ori: 0->1
				evalate_dis_removeN[0][1] = 0;    // pass
			}	
		}
	  else if(data[moving_position] - data[moving_position - 1] == 2) {
			evalate_dis_removeN[0][0] = 0;
			evalate_dis_removeN[1][0] = 1;
		}
		//i=1的情况单独处理
		else {
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position ] - 2 );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position ] - 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][1] = Dis;  // ori: 0->1
		}
		//i=1...remove_N-1集中处理
		for(int i=1; i<remove_N; i++){
			if(data[moving_position + i] - data[moving_position + i -1] == 1){
				evalate_dis_removeN[i][0] = 0;
				evalate_dis_removeN[i][0] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i - 1] - 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i] - 2 );
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][0] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i] - 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i - 1]);
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][1] = Dis;  // ori: 0->1
			}
		}

		if(remove_N + moving_position == data.size()-1 ) {
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[data.size()-1]);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
			evalate_dis_removeN[remove_N][0] = 0;  // pass
		}

		else if(remove_N + moving_position < data.size()){
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 + remove_N] - 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N] - 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - 1 + remove_N]);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
		}
		else {
			printf("please give a fit parameter about remove_N: the removing is too much!@");
		}
	}
	else{
		printf("Please output the right value, bool_n=: 1 or -1");
	}
	delete distmesh;
	delete gn_solver;
	delete input_data;
}


//上述的函数和该函数是一对，用于处于顺序和逆序的情况，为了方便实现功能，这里先这样搓的写着，后期优化代码。。。。。。。
void Calculate_Total_Evalation::Cal_Evalation_Update_TPN_second(std::vector<int> data, int moving_position,  int bool_n,  int sf_sum, int remove_N) {
	//the information of meshes, deformation and distance function
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;
	evalate_dis_removeN.resize(remove_N +1);
	for(int i=0; i<remove_N+1; i++){
		evalate_dis_removeN[i].resize(2);
	}
	char file_src[100],file_tar[100];
	if(bool_n == 1){ //关键帧移动位置加一操作
		if(moving_position == data.size()-1){
			if(data[moving_position] == sf_sum -2){
				evalate_dis_removeN[0][0] = 0;
				evalate_dis_removeN[1][0] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[1][0] = Dis;  // ori: 0->1
				evalate_dis_removeN[0][0] = 0;    // pass1
			}
		}
		else if(data[moving_position + 1] - data[moving_position] == 2) {
			evalate_dis_removeN[0][0] = 0;
			evalate_dis_removeN[0][1] = 0;
		}
		else {
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 2);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][1] = Dis;  // ori: 0->1
		}
		for(int i=1; i<remove_N; i++){
			if(data[moving_position - i + 1] - data[moving_position - i] == 1){
				evalate_dis_removeN[i][0] = 0;
				evalate_dis_removeN[i][1] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i] + 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i + 1] );
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][0] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i + 1] + 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - i] + 2);
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][1] = Dis;  // ori: 0->1
			}
		}
		if(moving_position - remove_N == -1){
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N + 1] );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1
			evalate_dis_removeN[remove_N][1] = 0;    // pass
		}
		else{
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N + 1] );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N + 1] + 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position - remove_N] + 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
		}
	}
	else if(bool_n == -1){ //关键帧位置减一操作
		if(data[moving_position + 1] - data[moving_position] == 2) {
			evalate_dis_removeN[0][0] = 0;
			evalate_dis_removeN[1][0] = 0;
		}
		else {
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 2 );
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + 1] - 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position] + 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[0][1] = Dis;  // ori: 0->1
		}
		for(int i=1; i<remove_N; i++){
			if(data[moving_position + i + 1] - data[moving_position + i] == 1){
				evalate_dis_removeN[i][0] = 0;
				evalate_dis_removeN[i][0] = 0;
			}
			else{
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i] - 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i + 1] - 2 );
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][0] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i + 1] - 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + i]);
				input_data->Init(file_src, file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter = 0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				evalate_dis_removeN[i][1] = Dis;  // ori: 0->1
			}
		}
	
		if(moving_position + remove_N == data.size() - 1){
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
			evalate_dis_removeN[remove_N][0] = 0;    // pass
		}
		else{
			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N] - 1);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N + 1] - 1);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			double Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][0] = Dis;  // ori: 0->1

			sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N + 1]);
			sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[moving_position + remove_N]);
			input_data->Init(file_src, file_tar);
			for (int iter = 0; iter < 1; ++iter) {
				input_data->GetIijSet();
			}
			//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
			gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
			for (int iter = 0; iter < 10; ++iter) {
				gn_solver->Run(1);
			}
			Dis = distmesh->Hausdorff_Average(input_data);
			evalate_dis_removeN[remove_N][1] = Dis;  // ori: 0->1
		}
	}
	else{
		printf("Please output the right value, bool_n=: 1 or -1");
	}

	delete distmesh;
	delete gn_solver;
	delete input_data;
}




//这部分主要用于插值算法的计算函数 Cal_Evalation_Interp_P and Cal_Evalation_Slack_P   input: data(关键帧序列),
// interp_dis_pos(选择的距离序列的某一位置), sf_sum(总的帧数)
//注意实际上需要的数据还有插入帧所在的关键帧距离的编号，看输入参数实际上是知道的
void Calculate_Total_Evalation::Cal_Evalation_Interp_P(std::vector<int> data, int interp_dis_pos, int order, int sf_sum) 
{	
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;
	if(order == 1){
		if(interp_dis_pos == 0) { // 此时为距离序列的第一个位置
			//初始化
			std::vector<double> dis_temp(4);
			double dis_max_value;
			interp_position = 1;

			dis_temp[0] = 0; dis_temp[1] = 0;
			char file_src[100],file_tar[100];
			if( data[interp_dis_pos] == 2) {
				dis_temp[2] = 0;  // ori: 0->1
				dis_temp[3] = 0;
			}
			else {
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 1 );
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] - 1);
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[2] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 2);
				input_data->Init(file_src,file_tar);
				for(int iter = 0; iter < 1; ++iter){
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for(int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[3] = Dis;  // ori: 0->1
			}
			if( dis_temp[2] < dis_temp[3]) {
				dis_max_value = dis_temp[3];
			}
			else{
				dis_max_value = dis_temp[2];
			}
			//迭代
			if(data[interp_dis_pos]  - data[interp_dis_pos-1] > 2){
				for(int i = 2; i<data[interp_dis_pos]; i++) {
					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0 );
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i - 1);
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[0] = Dis;  // ori: 0->1

					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i);
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 1);
					input_data->Init(file_src,file_tar);
					for(int iter = 0; iter < 1; ++iter){
						input_data->GetIijSet();
					}
					//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for(int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[1] = Dis;  // ori: 0->1	

					if(data[interp_dis_pos] - i == 1){
						dis_temp[2] = 0; 
						dis_temp[3] = 0;
					}
					else {
						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i );
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] - 1);
						input_data->Init(file_src,file_tar);
						for (int iter = 0; iter < 1; ++iter) {
							input_data->GetIijSet();
						}
						SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for (int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						double Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[0] = Dis;  // ori: 0->1

						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos]);
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i + 1);
						input_data->Init(file_src,file_tar);
						for(int iter = 0; iter < 1; ++iter){
							input_data->GetIijSet();
						}
						//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for(int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[2] = Dis;  // ori: 0->1	
					}
					//需要存储的是
					auto temp = max_element(dis_temp.begin(),dis_temp.end());
					if( dis_max_value > *temp ){
						interp_position = i;
					}
				}
			}
		}
		//else if(interp_dis_pos == data.size() - 1) {// 此时为距离序列的最后一个序列,由于是顺序这种可能是不存在的		
		//}
		else { // 此时为距离序列的中间一个序列
			//初始化
			std::vector<double> dis_temp(4);
			double dis_max_value;
			interp_position = data[interp_dis_pos - 1] + 1;

			dis_temp[0] = 0; dis_temp[1] = 0;
			char file_src[100],file_tar[100];
			if(data[interp_dis_pos] - data[interp_dis_pos-1] == 2) {
				dis_temp[2] = 0;  // ori: 0->1
				dis_temp[3] = 0;
			}
			else {
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos-1] + 1 );
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] - 1);
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[2] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos-1] + 2);
				input_data->Init(file_src,file_tar);
				for(int iter = 0; iter < 1; ++iter){
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for(int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[3] = Dis;  // ori: 0->1
			}
			if( dis_temp[2] < dis_temp[3]) {
				dis_max_value = dis_temp[3];
			}
			else{
				dis_max_value = dis_temp[2];
			}
			//迭代
			if(data[interp_dis_pos]  - data[interp_dis_pos-1] > 2){
				for(int i = data[interp_dis_pos-1] + 2; i<data[interp_dis_pos]; i++) {
					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos-1] );
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i - 1);
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[0] = Dis;  // ori: 0->1

					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i);
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos-1] + 1);
					input_data->Init(file_src,file_tar);
					for(int iter = 0; iter < 1; ++iter){
						input_data->GetIijSet();
					}
					//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for(int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[1] = Dis;  // ori: 0->1	

					if(data[interp_dis_pos] - i == 1){
						dis_temp[2] = 0; 
						dis_temp[3] = 0;
					}
					else {
						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i );
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] - 1);
						input_data->Init(file_src,file_tar);
						for (int iter = 0; iter < 1; ++iter) {
							input_data->GetIijSet();
						}
						SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for (int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						double Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[0] = Dis;  // ori: 0->1

						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos]);
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i + 1);
						input_data->Init(file_src,file_tar);
						for(int iter = 0; iter < 1; ++iter){
							input_data->GetIijSet();
						}
						//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for(int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[2] = Dis;  // ori: 0->1	
					}
					//需要存储的是
					auto temp = max_element(dis_temp.begin(),dis_temp.end());
					if( dis_max_value > *temp ){
						interp_position = i;
					}
				}
			}
		}
	}
	else if(order == -1) { // choose the opposite order as you want.
		//if(interp_dis_pos == 0) { // 此时为距离序列的第一个位置,这种情况在逆序的情况下是不会出现的
		//	printf("It's not allowed.");
		//}
		if(interp_dis_pos == data.size() - 1) {// 此时为距离序列的最后一个序列
			printf("testtest %d \n",interp_dis_pos);
			//初始化
			std::vector<double> dis_temp(4);
			double dis_max_value;
			interp_position = sf_sum - 1;

			dis_temp[2] = 0; dis_temp[3] = 0;
			char file_src[100],file_tar[100];
			if( data[interp_dis_pos] == sf_sum - 2) {
				dis_temp[0] = 0;  // ori: 0->1
				dis_temp[1] = 0;
			}
			else {
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] );
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum - 2);
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[2] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum - 1);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] + 1);
				input_data->Init(file_src,file_tar);
				for(int iter = 0; iter < 1; ++iter){
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for(int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[3] = Dis;  // ori: 0->1
			}
			if( dis_temp[2] < dis_temp[3]) {
				dis_max_value = dis_temp[3];
			}
			else{
				dis_max_value = dis_temp[2];
			}
			//迭代
			if(sf_sum  - data[interp_dis_pos] >= 2){
				for(int i = sf_sum - 2; i > data[interp_dis_pos]; i--) {
					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i );
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum - 1);
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[2] = Dis;  // ori: 0->1

					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i + 1);
					input_data->Init(file_src,file_tar);
					for(int iter = 0; iter < 1; ++iter){
						input_data->GetIijSet();
					}
					//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for(int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[3] = Dis;  // ori: 0->1	

					if(i - data[interp_dis_pos] == 1){
						dis_temp[0] = 0; 
						dis_temp[1] = 0;
					}
					else {
						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] );
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i-1);
						input_data->Init(file_src,file_tar);
						for (int iter = 0; iter < 1; ++iter) {
							input_data->GetIijSet();
						}
						SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for (int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						double Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[0] = Dis;  // ori: 0->1

						sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i);
						sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] + 1);
						input_data->Init(file_src,file_tar);
						for(int iter = 0; iter < 1; ++iter){
							input_data->GetIijSet();
						}
						//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
						gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
						for(int iter =0; iter < 10; ++iter) {
							gn_solver->Run(1);
						}
						Dis = distmesh->Hausdorff_Average(input_data);
						dis_temp[1] = Dis;  // ori: 0->1	
					}
					//需要存储的是
					auto temp = max_element(dis_temp.begin(),dis_temp.end());
					if( dis_max_value > *temp ){
						interp_position = i;
					}
				}
			}

		}
		else { // 此时为距离序列的中间一个序列 : 注，为了方便这里的循环的顺序和上述的循环的顺序是相反的，检查的时候是需要特别注意的
			printf("testtest2 %d\n", interp_dis_pos);
			double dis_max_value;
			//初始化
			std::vector<double> dis_temp(4);
			interp_position = data[interp_dis_pos] + 1;

			char file_src[100],file_tar[100];
			if(data[interp_dis_pos + 1] - data[interp_dis_pos] == 2) {
				interp_position = data[interp_dis_pos] + 1;
			}
			else {
				dis_temp[0] = 0; dis_temp[1] = 0;
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] + 1 );
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos+1] - 1);
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[2] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos+1]);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] + 2);
				input_data->Init(file_src,file_tar);
				for(int iter = 0; iter < 1; ++iter){
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for(int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[3] = Dis;  // ori: 0->1
			}
			if( dis_temp[2] < dis_temp[3]) {
				dis_max_value = dis_temp[3];
			}
			else{
				dis_max_value = dis_temp[2];
			}
			printf("test3\n");
			//迭代
			if(data[interp_position+1] - data[interp_position] > 2) {
			for(int i = data[interp_dis_pos] + 2; i<data[interp_dis_pos+1]; i++) {
				printf("test4\n");
				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] );
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i - 1);
				input_data->Init(file_src,file_tar);
				for (int iter = 0; iter < 1; ++iter) {
					input_data->GetIijSet();
				}
				SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for (int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				double Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[0] = Dis;  // ori: 0->1

				sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i);
				sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos] + 1);
				input_data->Init(file_src,file_tar);
				for(int iter = 0; iter < 1; ++iter){
					input_data->GetIijSet();
				}
				//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
				gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
				for(int iter =0; iter < 10; ++iter) {
					gn_solver->Run(1);
				}
				Dis = distmesh->Hausdorff_Average(input_data);
				dis_temp[1] = Dis;  // ori: 0->1	

				if(data[interp_dis_pos + 1] - i == 1){
					dis_temp[2] = 0; 
					dis_temp[3] = 0;
				}
				else {
					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i );
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos+1] - 1);
					input_data->Init(file_src,file_tar);
					for (int iter = 0; iter < 1; ++iter) {
						input_data->GetIijSet();
					}
					SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for (int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					double Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[2] = Dis;  // ori: 0->1

					sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[interp_dis_pos+1]);
					sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", i + 1);
					input_data->Init(file_src,file_tar);
					for(int iter = 0; iter < 1; ++iter){
						input_data->GetIijSet();
					}
					//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
					gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
					for(int iter =0; iter < 10; ++iter) {
						gn_solver->Run(1);
					}
					Dis = distmesh->Hausdorff_Average(input_data);
					dis_temp[3] = Dis;  // ori: 0->1	
				}
				//需要存储的是
				auto temp = max_element(dis_temp.begin(),dis_temp.end());
				if( dis_max_value > *temp ){
					interp_position = i;
				}
			}
			}
		}
	}
	else {
		printf("Please input the right order 1 or -1, it represents the order of our data!!!");
	}
	delete distmesh;
	delete gn_solver;
	delete input_data;
}


// 去掉一个关键帧的，并输出该需要去掉的关键帧的编号
void Calculate_Total_Evalation::Cal_Evalation_Slack_P(std::vector<int> data,  int sf_sum) 
{
	InputData *input_data = new InputData;
	GNSolver *gn_solver = new GNSolver;
	DisTwoMesh *distmesh = new DisTwoMesh;

	//选出最小的两段关键帧的距离，并输出该准备丢失的关键帧
	//初始化
	std::vector<double> dis_temp(2);
	double key_dis_two;
	slack_position = data[0];

	char file_src[100],file_tar[100];
	sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
	sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[1]);
	input_data->Init(file_src,file_tar);
	for (int iter = 0; iter < 1; ++iter) {
		input_data->GetIijSet();
	}
	SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
	gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
	for (int iter =0; iter < 10; ++iter) {
		gn_solver->Run(1);
	}
	double Dis = distmesh->Hausdorff_Average(input_data);
	dis_temp[0] = Dis;  // ori: 0->1

	sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[1]);
	sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", 0);
	input_data->Init(file_src,file_tar);
	for(int iter = 0; iter < 1; ++iter){
		input_data->GetIijSet();
	}
	//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
	gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
	for(int iter =0; iter < 10; ++iter) {
		gn_solver->Run(1);
	}
	Dis = distmesh->Hausdorff_Average(input_data);
	dis_temp[1] = Dis;  // ori: 0->1	
	
	if(dis_temp[0] > dis_temp[1]) {//我们是选择两者的最大值
		key_dis_two = dis_temp[0];
	}
	else{
		key_dis_two = dis_temp[1];
	}

	sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[data.size()-2]);
	sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
	input_data->Init(file_src,file_tar);
	for (int iter = 0; iter < 1; ++iter) {
		input_data->GetIijSet();
	}
	//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
	gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
	for (int iter =0; iter < 10; ++iter) {
		gn_solver->Run(1);
	}
	Dis = distmesh->Hausdorff_Average(input_data);
	dis_temp[0] = Dis;  // ori: 0->1

	sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", sf_sum);
	sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[data.size()-2]);
	input_data->Init(file_src,file_tar);
	for(int iter = 0; iter < 1; ++iter){
		input_data->GetIijSet();
	}
	//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
	gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
	for(int iter =0; iter < 10; ++iter) {
		gn_solver->Run(1);
	}
	Dis = distmesh->Hausdorff_Average(input_data);
	dis_temp[1] = Dis;  // ori: 0->1	
	
	//printf("second step: dis_temp0 %f ,dis_temp1 %f\n ", dis_temp[0], dis_temp[1]);
	if(dis_temp[0] < dis_temp[1]) {
		dis_temp[0] = dis_temp[1];
	}
	if(dis_temp[0] < key_dis_two){
		slack_position = data.size()-1;
	}
	
	// start the circle
	for(int i= 0; i<data.size()-2; i++){
		sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]);
		sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i+2] -1);
		input_data->Init(file_src,file_tar);
		for (int iter = 0; iter < 1; ++iter) {
			input_data->GetIijSet();
		}
		//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
		gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
		for (int iter =0; iter < 10; ++iter) {
			gn_solver->Run(1);
		}
		Dis = distmesh->Hausdorff_Average(input_data);
		dis_temp[0] = Dis;  // ori: 0->1
		
		sprintf(file_src, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i+2]);
		sprintf(file_tar, "/data/workspace/Offline4D/data/168/mesh/mesh%d.obj", data[i]+1);
		input_data->Init(file_src,file_tar);
		for(int iter = 0; iter < 1; ++iter){
			input_data->GetIijSet();
		}
		//SolverPara gnsolver_param(true, 10.0f, false, 3.0f, true, 3.0f, 1, 1000.0f);
		gn_solver->InitSovler(input_data, gnsolver_param); //error: InitSovler? -->InitSolver
		for(int iter =0; iter < 10; ++iter) {
			gn_solver->Run(1);
		}
		Dis = distmesh->Hausdorff_Average(input_data);
		dis_temp[1] = Dis;  // ori: 0->1	
	
		//printf("second step: dis_temp0 %f ,dis_temp1 %f\n ", dis_temp[0], dis_temp[1]);
		if(dis_temp[0] < dis_temp[1]) {
			dis_temp[0] = dis_temp[1];
		}
		if(dis_temp[0] < key_dis_two){
			slack_position = i+1;
		}
	}
}
